<%--
  Created by IntelliJ IDEA.
  User: 郑浩
  Date: 2021/1/25
  Time: 16:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--
     request对象获取Cookie
--%>
<%
    //声明变量接收用户名和密码
    String name = "";
    String pwd = "";
    String cked = "";
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            System.out.println(cookie.getName() + "," + cookie.getValue());
            if ("username".equals(cookie.getName())) {
                name = cookie.getValue();
                cked = "checked";
            }
            if ("password".equals(cookie.getName())) {
                pwd = cookie.getValue();
            }
        }
    }
%>
<form action="/login/test1" method="post">
    username:<input type="text" name="username" value="<%=name%>"/><br/>
    password:<input type="text" name="password" value="<%=pwd%>"/><br/>
    记住我<input type="checkbox" name="remember" value="1" <%=cked%>/><br/>
    <input type="submit" value="登录">
</form>
</body>
</html>
